﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using StackExchange.Redis;

namespace Medical.ReadApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class TestController : ControllerBase
    {
        private readonly IDatabase _redisDatabase;
        public TestController(IConnectionMultiplexer redis)
        {
            _redisDatabase = redis.GetDatabase();
        }
        [HttpGet]
        public string Get()
        {
            //写入string 
            var res = _redisDatabase.StringSet("userName", "admin",TimeSpan.FromSeconds(20));
            Thread.Sleep(10000);
            //读取
            var value = _redisDatabase.StringGet("userName");

            var result = value.ToString();


            return value;
        }
    }
}
